
from django.template import loader
from django.test import TestCase


def generate_test_html():
    '''测试生成静态页面'''

    template = loader.get_template('test2.html')

    context = {'city':'北京',
               'adict':{
               'name':'西游记',
               'author':'安智军',
               },
               'alist':[1,2,3,4,5]

               }

    # 渲染模版
    # return HttpResponse(template.render(context))
    html_str = template.render(context)
    print(html_str)

    # 保存生成的静态内容到：front_end_pc/test3.html
    file_path = '/home/python/Destop/meiduo/front_end_pc/test2.html'
    with open(file_path, 'w') as file:
        file.write(html_str)